﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// 集合扩展类
/// </summary>
public static class IListExtensions
{
    /// <summary>
    /// 在指定位置处插入集合
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="target"></param>
    /// <param name="index"></param>
    /// <param name="toAdd"></param>
    public static  void InsertRange<T>(this IList<T> target, int index, IEnumerable<T> toAdd)
    {
        foreach (T item in toAdd)
        {
            target.Insert(index++, item);
        }
    }

    /// <summary>
    /// 追加集合
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="target"></param>
    /// <param name="source"></param>
    public static void AddRange<T>(this IList<T> target, IEnumerable<T> source)
    {
        foreach (T item in source)
        {
            target.Add(item);
        }
    }
}

